<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var num = prompt('请输入一个数：') * 1;

        function zhiShu(num) {
            if (num <= 1) {
                return false;
            } 
                for (var i = 2; i < num; i++) {
                    if (num % i == 0) {
                        return false;
                        break;
                    }
                }
                return true;
            
        }
        if (zhiShu(num)) {
            alert(num + '是质数')
        } else {
            alert(num + '不是质数')
        }
    </script>
</body>

</html>